package com.api.shopapi.service.impl;


import com.api.shopapi.entity.Menu;
import com.api.shopapi.mapper.MenuMapper;
import com.api.shopapi.service.MenuService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("MenuServiceImplOne")
public class MenuServiceImpl implements MenuService {

    @Autowired
    private MenuMapper menuMapper;



    @Override
    public int insert(Menu menu){
        return menuMapper.insert(menu);
    }

    @Override
    public int deleteByMenuCode(String menuCode){
        return menuMapper.deleteByMenuCode(menuCode);
    }

    @Override
    public int updateByMenuCode(Menu menu){
        return menuMapper.updateByMenuCode(menu);
    }

    @Override
    public Menu getByMenuCode(String menuCode){
        return menuMapper.getByMenuCode(menuCode);
    }

    @Override
    public List<Menu> getList() {
        return menuMapper.getList();
    }

    @Override
    public List<Menu> getListByParentMenuCode(String parentMenuCode){
        return menuMapper.getListByParentMenuCode(parentMenuCode);
    }

    @Override
    public List<Menu> getListByRoleCodeParentMenuCode(String roleCode,String parentMenuCode){
        return menuMapper.getListByRoleCodeParentMenuCode(roleCode,parentMenuCode);
    }


    @Override
    public PageInfo<Menu> getPageInfo(int pageNum, int pageSize){
        PageHelper.startPage(pageNum, pageSize);
        List<Menu> listMenu = menuMapper.getList();
        PageInfo<Menu> pageInfo = new PageInfo<Menu>(listMenu);
        return pageInfo;
    }

}
